import { MenuItemDefinition } from '@amcax/base';
import { ProductTreeNode } from '../../types';
import { ConstraintType } from '@app-cad-env/product/commands/cmd-constrain/type';
import { cmdConstrain } from '@app-cad-env/product/commands/cmd-constrain';

export const editAssemblyConstraint: MenuItemDefinition<ProductTreeNode> = {
  id: 'edit-assembly-constraint',
  children: '编辑',
  hidden: ({ props: { type, originalObj } }) =>
    type !== 'assembly-constraint' || originalObj.type === ConstraintType.Fix,
  onClick: async ({ data: { invokeCmd }, props: { originalObj } }) => {
    invokeCmd(cmdConstrain, originalObj);
  },
};
